class Solution(object):
    def maxChunksToSorted(self, arr):
        """
        :type arr: List[int]
        :rtype: int
        """
        max_val = -1
        count = 0
        for i, val in enumerate(arr):
            max_val = max(max_val, val)
            if max_val == i:
                count += 1
        return count


data = Solution()
arr = [4, 3, 2, 1, 0]
print(data.maxChunksToSorted(arr))
